var rootPath = getRootPath();

$(document).ready(function(){

	$.ajax({
		method : 'get',
		url : rootPath+'/wechat/api/potentialUsers/myMessage',
		error:function(XMLHttpRequest, ajaxOptions, thrownError){
			alert("刷新数据失败！");
		},
		success : function(resultData){

			var wholeHtml = '';
			
			$.each(resultData,function(myMessageIndex,myMessageObj){
				var myMessageHtml = '';
				var icon = '';
				var type = '';
				var content = myMessageObj.myContent.replace(/null/g," ").replace(/{{/g,"").replace(/}}/g,"<br>");
				if(myMessageObj.templateNum=='TM00629'||myMessageObj.templateNum=='TM00627'||myMessageObj.templateNum=='OPENTM401181167'){
					icon = 'glyphicon glyphicon-bell';
					type = '用车提醒';
				}
				
				myMessageHtml = myMessageHtml + '<div class="panel panel-default" style="padding-left:5%;padding-right:5%;">'
											  + '<span style="left:2%;font-family:黑体;font-size:15px;">'+ type +'</span>'
											  + '<span style="float:right">'+ myMessageObj.createDate +'</span><br>'
											  + '<span style="font-family:宋体;font-size:10px;color:gray;">'+ content +'</span>'
											  + '</div>'
											  
				wholeHtml += myMessageHtml;							  
			});

			$("#myMessage").append(wholeHtml);
		}
	});
})